package com.jn.erp.web.api.student.controller;

import com.jn.erp.common.core.page.TableDataInfo;
import com.jn.erp.common.core.result.AjaxResult;
import com.jn.erp.security.controller.BaseWebAuthController;
import com.jn.erp.web.api.student.entity.TRenewalAlertsConfig;
import com.jn.erp.web.api.student.entity.dto.StudentRenewalDto;
import com.jn.erp.web.api.student.service.RenewalAlertsConfigService;
import com.jn.erp.web.api.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/renewalAlerts")
public class RenewalAlertsController extends BaseWebAuthController {

    @Autowired
   private StudentService studentService;

    @Autowired
   private RenewalAlertsConfigService renewalAlertsConfigService;

    /**
     * 预警列表
     */
    @GetMapping("/alertsList")
    public TableDataInfo auditionList(StudentRenewalDto studentRenewalDto) {
        startPage();
        studentRenewalDto.setOrgId(Long.parseLong(loginDeptAuth()));
        List<StudentRenewalDto> list = studentService.alertsList(studentRenewalDto);
        return getDataTable(list);
    }

    /**
     * 预警设置
     */
    @PostMapping("/alertSettings")
    public AjaxResult alertSettings(StudentRenewalDto studentRenewalDto) {
        studentRenewalDto.setOrgId(Long.parseLong(loginDeptAuth()));
        renewalAlertsConfigService.alertSettings(studentRenewalDto);
        return success("设置成功");
    }

    /**
     * 预警设置
     */
    @PostMapping("/settingsList")
    public AjaxResult settingsList(TRenewalAlertsConfig tRenewalAlertsConfig) {
        tRenewalAlertsConfig.setOrgId(Long.parseLong(loginDeptAuth()));
        TRenewalAlertsConfig setting =  renewalAlertsConfigService.settingsList(tRenewalAlertsConfig);
        return success("设置成功");
    }

}
